<html>
<head><meta charset="utf-8"><title>wasm32 core and std relocation model? · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/wasm32.20core.20and.20std.20relocation.20model.3F.html">wasm32 core and std relocation model?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="205447393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/wasm32%20core%20and%20std%20relocation%20model%3F/near/205447393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/wasm32.20core.20and.20std.20relocation.20model.3F.html#205447393">(Jul 30 2020 at 07:07)</a>:</h4>
<p>I asked this question here first: <a href="https://users.rust-lang.org/t/unable-to-build-shared-wasm-lib-becuase-core-is-not-built-with-fpic/46549/2">https://users.rust-lang.org/t/unable-to-build-shared-wasm-lib-becuase-core-is-not-built-with-fpic/46549/2</a> but got no answers so wanted to ask here as well. Basically the problem is I'm unable to make shared libraries of my Rust crates if I use function from core or std and I think the problem is because core and std are not built with PIC relocation model. I'd like to try building rustc with std and core built with PIC for wasm32. Can anyone help me on this? I'm not sure what to update in config.toml.</p>



<a name="205451552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/wasm32%20core%20and%20std%20relocation%20model%3F/near/205451552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pachi <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/wasm32.20core.20and.20std.20relocation.20model.3F.html#205451552">(Jul 30 2020 at 08:06)</a>:</h4>
<p><span class="user-mention" data-user-id="119169">@osa1</span> I don't know how to do it, but I know there's xargo for that usecase <a href="https://github.com/japaric/xargo">https://github.com/japaric/xargo</a> but maybe there's a simpler way. IIRC there has been some work to make it easier.</p>



<a name="205452957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/wasm32%20core%20and%20std%20relocation%20model%3F/near/205452957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/wasm32.20core.20and.20std.20relocation.20model.3F.html#205452957">(Jul 30 2020 at 08:24)</a>:</h4>
<p>Oh wow ... it only took 30 seconds and it worked! I'm surprised how fast it build <code>core</code> from scratch.. I only had to create <code>.cargo/config</code> with these lines:</p>
<div class="codehilite"><pre><span></span><code>[build]
rustflags = [&quot;-Crelocation-model=pic&quot;]
</code></pre></div>



<a name="205452966"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/wasm32%20core%20and%20std%20relocation%20model%3F/near/205452966" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/wasm32.20core.20and.20std.20relocation.20model.3F.html#205452966">(Jul 30 2020 at 08:24)</a>:</h4>
<p>Thanks!</p>



<a name="205453287"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/wasm32%20core%20and%20std%20relocation%20model%3F/near/205453287" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pachi <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/wasm32.20core.20and.20std.20relocation.20model.3F.html#205453287">(Jul 30 2020 at 08:28)</a>:</h4>
<p>Glad it helped!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>